package com.cms.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.cms.bean.CodeBean;
import com.cms.sqlMap.SqlMapConfig;
import com.ibatis.sqlmap.client.SqlMapClient;

public class CodeAction extends DispatchAction {

	private Log log = LogFactory.getFactory().getInstance(this.getClass().getName());
	private SqlMapClient sqlMap = SqlMapConfig.getSqlMapInstance();
	
	@SuppressWarnings("rawtypes")
	public ActionForward codeList(ActionMapping mapping,
				     ActionForm form,
				     HttpServletRequest request,
				     HttpServletResponse response) throws Exception {
		
		CodeBean bean = (CodeBean) form;
		
		bean.setP_code(bean.getP_code());
		List list = sqlMap.queryForList("Code.code-list", bean);
		
		request.setAttribute("list", list);
		
		return mapping.findForward("list");
		
	}
}
